package com.project.controller;

import com.framework.core.result.APIObjResponse;
import com.project.base.BaseController;
import com.project.biz.CmsHomeConfBiz;
import com.project.pojo.dto.HomeDTO;
import com.project.pojo.model.AddHomeConfModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @Description: 首页、统计等
 * @Author: zhuchi
 * @CreateDate: 2020/11/20 1:24
 * @Version: 1.0
 */
@Api(value = "HomeController", description = "首页、统计等")
@RestController
@RequestMapping("/home")
@Slf4j
public class HomeController extends BaseController {

    /**
     * 移动端首页配置业务层接口类
     */
    @Autowired
    private CmsHomeConfBiz homeConfBiz;

    /**
     * 获取移动端首页配置
     * @return
     */
    @ApiOperation(value = "获取移动端首页配置")
    @GetMapping(value = "/getHomeConf")
    public APIObjResponse<HomeDTO> getHomeConf(){
        HomeDTO homeDTO = this.homeConfBiz.getHomeConf();
        return APIObjResponse.success("查询成功", homeDTO);
    }

    /**
     * 添加移动端首页配置
     * @param addHomeConfModel
     * @return
     */
    @ApiIgnore
    @ApiOperation(value = "添加移动端首页配置")
    @PostMapping(value = "/addHomeConfModel")
    public APIObjResponse<Integer> addHomeConfModel(@RequestBody AddHomeConfModel addHomeConfModel){
        int result = this.homeConfBiz.updateHomeConf(addHomeConfModel);
        return APIObjResponse.success("操作成功", result);
    }

}
